/*
 * ColorAction.java
 *
 * Created on February 8, 2007, 8:29 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.bff.mpd.musicjukebox.lib.actions;

import com.bff.mpd.utils.Utils;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JColorChooser;

/**
 *
 * @author bill
 */
public class ColorAction extends AbstractAction {

    private Component parent;
    private Component compToColor;
    private Color chosenColor;

    /** Creates a new instance of ColorAction */
    public ColorAction(Component parent, Component compToColor) {
        this.parent = parent;
        this.compToColor = compToColor;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        chosenColor = JColorChooser.showDialog(
                this.parent,
                Utils.getMessage("ACTION_COLOR_NAME"),
                Color.GRAY);
        if (chosenColor != null) {
            this.compToColor.setBackground(chosenColor);
            this.compToColor.setForeground(chosenColor);
        }
    }

    public Color getChosenColor() {
        return chosenColor;
    }
}
